package com.ktgj.hotel.exception;

/**
 * @Author: likeli
 * @Description: 自定义友好异常，通常用于业务提示
 * @Data: Create in 2018/5/18 上午10:29
 * @Modificd_By:
 */
public class FriendlyException extends RuntimeException {

    /**
     * 状态码
     */
    private int status;

    /**
     * Constructs a new exception with {@code null} as its detail message.
     * The cause is not initialized, and may subsequently be initialized by a
     * call to {@link #initCause}.
     */
    public FriendlyException() {
    }

    /**
     * Constructs a new exception with the specified detail message.  The
     * cause is not initialized, and may subsequently be initialized by
     * a call to {@link #initCause}.
     *
     * @param message the detail message. The detail message is saved for
     *                later retrieval by the {@link #getMessage()} method.
     */
    public FriendlyException(String message) {
        super(message);
    }

    /**
     * Constructs a new exception with the specified detail message.  The
     * cause is not initialized, and may subsequently be initialized by
     * a call to {@link #initCause}.
     *
     * @param message the detail message. The detail message is saved for
     *                later retrieval by the {@link #getMessage()} method.
     */
    public FriendlyException(String message, int status) {
        super(message);

        if (status == 0) {
            this.status = 10000;
        } else {
            this.status = status;
        }
    }

    public int getStatus() {
        return status;
    }
}
